﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace DIProject.Dictionary
{
    public partial class MedForm : Form
    {
        public MedForm()
        {
            InitializeComponent();
        }

        private void MedForm_Load(object sender, EventArgs e)
        {
            InitMedForm();
        }
        private void InitMedForm()
        {
            this.medFormTableAdapter.Fill(this.dictionary.MedForm, DIProject.Data.Sync.IsAdmin);
            lblStatus.Text = "Всего найдено: " + this.dictionary.MedForm.Count.ToString();
        }

        private void dataGridView1_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
        {
            dataGridView1.Rows[e.RowIndex].Selected = true;
            DataRowView drv = dataGridView1.SelectedRows[0].DataBoundItem as DataRowView;
            if (drv != null)
            {
                DataSets.Dictionary.MedFormRow mr = drv.Row as DataSets.Dictionary.MedFormRow;
                if (mr != null)
                {
                    MedFormDetails mfd = new MedFormDetails(Util.ActionType.Update, mr.Id, this);
                    mfd.ShowDialog(this);
                }
            }
        }

        private void toolStripButton2_Click(object sender, EventArgs e)
        {
            InitMedForm();
        }

        private void toolStripButton1_Click(object sender, EventArgs e)
        {
            MedFormDetails mfd = new MedFormDetails(Util.ActionType.Insert, Int32.MinValue, this);
            mfd.ShowDialog(this);
        }
    }
}